<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/6/9
 * Time: 18:16
 */

namespace App\Http\Controllers\Service;
use App\Http\Controllers\CommonController;
use App\Http\Model\CategoryModel;
use Symfony\Component\HttpFoundation\Request;

class CategoryController extends CommonController {
    private $CategoryModel = null;

    function __construct() {
        $this->CategoryModel = new CategoryModel();
    }

    public function getCategories(Request $request) {
        if($request->isMethod('POST')){
            $parentId = $request->input('parentId','1');
            $childCateNames = $this->CategoryModel->getChildCategories($parentId,['CateName','CateId']);
            exit(responseJson(1,'查询成功',$childCateNames));
        }
        return view('category',[
            'parentCates'=> $this->CategoryModel->getParentCategories(['CateName','CateId']),
            //'childCateNames' => $this->CategoryModel->getChildCategories(1,['CateName','CateId'])
        ]);
    }


}